(function($) {
    $.customShare=function(){
        var $customShare={};
        $customShare.methods={
            init:function(){
                $customShare.sinaUrl="http://service.weibo.com/share/share.php?url=地址&title=标题&pic=图片&searchPic=false&sudaref=&appkey=来源";
                $customShare.renrenUrl="http://widget.renren.com/dialog/share?resourceUrl=地址&srcUrl=地址&title=&description=&pic=图片&message=标题";
                $customShare.doubanUrl="http://www.douban.com/share/service?href=地址&name=标题&text=&image=图片";
                $customShare.qzoneUrl="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=地址&desc=标题&pics=图片&summary=&ptlang=2052";
                $customShare.qqUrl="http://share.v.t.qq.com/index.php?c=share&a=index&url=地址&title=标题&pic=图片&appkey=来源";
                $customShare.facebookUrl="https://www.facebook.com/sharer/sharer.php?s=100&p[title]=标题&p[url]=地址&p[images]=图片";
                $customShare.twitterUrl="https://twitter.com/intent/tweet?url=地址&text=标题&pic=图片";
                $customShare.googleUrl="https://plus.google.com/share?url=地址&t=标题&pic=图片";
            },
            getShare:function(str,parameter){
                window.open($customShare.Resolve($customShare.getUrl(str),parameter.url||"",parameter.title||"",parameter.pic||"",parameter.appkey||""),"_blank",'height=500,width=800,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
            },
            getWeixinShare:function(url,width,height){
                if($("body .weixinBox").length>0)return false;
                var _qrWidth=width||200;
                var _qrHeight=height||200;
                var _type="table";
                var str='<div class="weixinBox"><p>分享到微信</p><span>x</span><div class="weixinQR"></div><em style="display:block;height:20px; line-height:20px; text-align:center">扫一扫分享链接</em></div>';
                $("body").append(str);
                if(!!document.createElement('canvas').getContext){_type="canvas";}
                $('.weixinQR').qrcode({render:_type,width: _qrWidth,height:_qrHeight,text: url});
                $(".weixinBox span").bind("click",function(){$(".weixinBox").remove();});
            }
        };
        $customShare.Resolve=function (str,url,title,pic,appkey){
            return str.replace(/地址/g, encodeURIComponent(url)).replace(/标题/g, encodeURIComponent(title)).replace(/图片/g, pic).replace(/来源/g,appkey);
        };
        $customShare.getUrl=function(key){
            if(key=="sina")return $customShare.sinaUrl;
            if(key=="renren")return $customShare.renrenUrl;
            if(key=="douban")return $customShare.doubanUrl;
            if(key=="qzone")return $customShare.qzoneUrl;
            if(key=="qq")return $customShare.qqUrl;
            if(key=="facebook")return $customShare.facebookUrl;
            if(key=="twitter")return $customShare.twitterUrl;
            if(key=="google")return $customShare.googleUrl;
        };
        $customShare.methods.init();
        return $customShare.methods;
    };
 })(jQuery);